/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pkgjeudestrategie;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

/**
 *
 * @author Alex
 */
public class FenetreChoixQuitter extends JFrame {

    String question = "Question Oui/Non";
    JButton btnOui = new JButton("Oui");
    JButton btnNon = new JButton("Non");
    JLabel lblQuestion = new JLabel("");
    boolean reponse = false;
    String sReponse = "";
    FenetreMenuEsc menu;

    public FenetreChoixQuitter(String question,FenetreMenuEsc menu) {
        this.question = question;
        this.menu=menu;
        setLayout(new BorderLayout());
        add(new JLabel(question, JLabel.CENTER), BorderLayout.NORTH);
        JPanel pnl = new JPanel();
        pnl.setLayout(new GridLayout(0,2));
        pnl.add(btnOui);
        pnl.add(btnNon);
        add(pnl,BorderLayout.CENTER);
        setUndecorated(true);
        setSize(360, 100);
        setLocation((int) (Fenetre.tailleX / 2 - getWidth() / 2),
                (int) (Fenetre.tailleY / 2 - getHeight() / 2));
        setVisible(true);
        question();

    }
public boolean getReponse(){
    return reponse;
}
    public void question() {
            btnOui.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
               whatItIs("oui");
                //dispose();

            }
        });

        btnNon.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent ae) {
               whatItIs("non");
               menu.setEnabled(true);
               dispose();


            }
        });

            
    }
    public void whatItIs(String s){
        if (s.equalsIgnoreCase("oui")){
            System.exit(0);
        } else {
           return;
        }
        
    }
}
